package com.im.partchat.http.interceptor;

import android.text.TextUtils;

import com.im.partchat.App;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class HeaderInterceptor implements Interceptor {

        @Override
        public Response intercept(Chain chain) throws IOException {

            Request.Builder builder = chain.request().newBuilder();
            builder.addHeader("Content-Type", "application/json;charset=UTF-8");
            if (App.getUserBean()!=null&&!TextUtils.isEmpty(App.getUserBean().getJwtToken())){
                builder .addHeader("Authorization", "Bearer:"+App.getUserBean().getJwtToken());
            }
            Request request =builder .build();
            return chain.proceed(request);
        }
    }